<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>搜索结果 - GameStore</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <!-- Tailwind CSS 配置 -->
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#165DFF',
                        secondary: '#36CFC9',
                        accent: '#722ED1',
                        dark: '#1D2129',
                        light: '#F2F3F5'
                    },
                    fontFamily: {
                        inter: ['Inter', 'system-ui', 'sans-serif'],
                    },
                }
            }
        }
    </script>
</head>
<body class="font-inter bg-gray-50 text-dark">
<!-- 导航栏 -->
<header class="fixed top-0 left-0 right-0 z-50 bg-white navbar-shadow transition-all duration-300">
    <div class="container mx-auto px-4">
        <div class="flex items-center justify-between h-16 md:h-20">
            <!-- Logo -->
            <a href="/home" class="flex items-center space-x-2">
                <div class="w-10 h-10 rounded-lg bg-primary flex items-center justify-center">
                    <i class="fa fa-gamepad text-white text-xl"></i>
                </div>
                <span class="text-xl font-bold text-dark">GameStore</span>
            </a>
        </div>
    </div>
</header>
<!-- search页面搜索结果区域 -->
<section>
    <div class="mb-6 flex justify-between items-center">
        <h2 class="text-2xl font-bold">搜索结果: <span class="text-primary" th:text="${searchKey}">无关键词</span></h2>
        <a href="#" th:href="@{/}" class="text-gray-500 hover:text-primary transition-colors">
            <i class="fa fa-home mr-1"></i> 返回首页
        </a>
    </div>

    <div id="search-results" class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6">
        <!-- 调试区域：显示游戏列表大小 -->
        <div class="text-center text-gray-500 mb-4" th:text="|共找到 ${#lists.size(games)} 个游戏|"></div>

        <!-- 有搜索结果时显示 -->
        <div th:if="${not #lists.isEmpty(games)}">
            <div th:each="game : ${games}" class="bg-white rounded-xl shadow-md overflow-hidden hover-scale">
                <!-- 添加链接 -->
                <a th:href="@{/{id}.html(id=${game.id})}">
                    <img th:src="${game.imageUrl}" alt="${game.name} 游戏封面" class="w-full h-48 object-cover">
                    <div class="p-4">
                        <h3 th:text="${game.name}" class="font-bold text-lg mb-2"></h3>
                        <p th:text="${game.description}" class="text-gray-600 text-sm mb-4"></p>
                        <div class="flex justify-between items-center">
                            <span th:text="|¥${game.price}|" class="font-bold text-primary"></span>
                            <button class="px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary/90 transition-colors">
                                <i class="fa fa-shopping-cart mr-1"></i> 加入购物车
                            </button>
                        </div>
                    </div>
                </a>
            </div>
        </div>

        <!-- 无搜索结果时显示 -->
        <div th:unless="${not #lists.isEmpty(games)}" class="col-span-full text-center py-12">
            <i class="fa fa-search text-6xl text-gray-300 mb-4"></i>
            <h3 class="text-xl font-medium mb-2">未找到"[[${searchKey}]]"相关游戏</h3>
            <p class="text-gray-600">
                尝试：<br>
                <span class="text-sm text-gray-500">
                    • 检查关键词拼写<br>
                    • 使用更简单的关键词（如"赛车"代替"超级赛车冒险"）<br>
                    • 浏览<a th:href="@{/}">全部游戏</a>
                </span>
            </p>
        </div>
    </div>
</section>
<!-- 页脚 -->
<footer class="bg-dark text-white py-12">
    <div class="container mx-auto px-4">
        <div class="grid grid-cols-1 md:grid-cols-4 gap-8">
            <div>
                <h3 class="text-lg font-bold mb-4">GameStore</h3>
                <p class="text-gray-400">发现最新、最热门的游戏，开启你的游戏之旅。</p>
            </div>
            <div>
                <h3 class="text-lg font-bold mb-4">快速链接</h3>
                <ul class="space-y-2">
                    <li><a href="/home" class="text-gray-400 hover:text-white transition-colors">首页</a></li>
                    <li><a href="/gamelist" class="text-gray-400 hover:text-white transition-colors">游戏分类</a></li>
                    <li><a href="#" class="text-gray-400 hover:text-white transition-colors">新上架</a></li>
                </ul>
            </div>
            <div>
                <h3 class="text-lg font-bold mb-4">支持</h3>
                <ul class="space-y-2">
                    <li><a href="#" class="text-gray-400 hover:text-white transition-colors">帮助中心</a></li>
                </ul>
            </div>
        </div>
    </div>
</footer>
</body>
</html>